Learn R Programming

Compositional (version 5.5)

Constrained linear least squares for compositional responses and predictors: Constrained linear least squares for compositional responses and predictors

Description

Constrained linear least squares for compositional responses and predictors.

Usage

ols.compcomp(y, x, rs = 5, tol = 1e-4, xnew = NULL)

Arguments

y

A matrix with the compositional data (dependent variable). Zero values are allowed.

x

A matrix with the compositional predictors. Zero values are allowed.

rs

The number of times to run the constrained optimisation using different random starting values each time.

tol

The threshold upon which to stop the iterations of the constrained optimisation.

xnew

If you have new data use it, otherwise leave it NULL.

Value

A list including:

runtime

The time required by the regression.

mse

The mean squared errors.

be

The beta coefficients.

est

The fitted of xnew if xnew is not NULL.

Details

The function performs least squares regression where the beta coefficients are constained to be positive and sum to 1. We were inspired by the transformation-free linear regression for compositional responses and predictors of Fiksel, Zeger and Datta (2020).

References

Jacob Fiksel, Scott Zeger and Abhirup Datta (2020). A transformation-free linear regression for compositional outcomes and predictors. https://arxiv.org/pdf/2004.07881.pdf

See Also

cv.olscompcomp, tflr, kl.alfapcr

Examples

Run this code
# NOT RUN {
library(MASS)
set.seed(1234)
y <- rdiri(214, runif(4, 1, 3))
x <- as.matrix(fgl[, 2:9])
x <- x / rowSums(x)
mod <- ols.compcomp(y, x, rs = 1)
mod
# }

Run the code above in your browser using DataLab